From aa6652aac7f6bcf61df111f5ce81c656086e3249 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 16 Jun 2014 22:13:07 +0200 Subject: [PATCH] cssprovider: Names starting with -gtk- aren't style props We want to have the "-gtk-" prefix for our custom CSS properties. But we also want to parse names starting with a "-" as style properties. So make sure that "-gtk-" is treated like a normal property and we emit errors when somebody uses it wrong. This is to catch errors with people typing -gtk-iconsource: none; instead of the correct -gtk-icon-source: none; --- gtk/gtkcssprovider.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 242f1b9327..30881beda1 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2342,6 +2342,18 @@ parse_selector_list (GtkCssScanner *scanner) return selectors; } +static gboolean +name_is_style_property (const char *name) +{ + if (name[0] != '-') + return FALSE; + + if (g_str_has_prefix (name, "-gtk-")) + return FALSE; + + return TRUE; +} + static void parse_declaration (GtkCssScanner *scanner, GtkCssRuleset *ruleset) @@ -2356,7 +2368,7 @@ parse_declaration (GtkCssScanner *scanner, goto check_for_semicolon; property = _gtk_style_property_lookup (name); - if (property == NULL && name[0] != '-') + if (property == NULL && !name_is_style_property (name)) { gtk_css_provider_error (scanner->provider, scanner, @@ -2441,7 +2453,7 @@ parse_declaration (GtkCssScanner *scanner, gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE); } - else if (name[0] == '-') + else if (name_is_style_property (name)) { char *value_str; -- 2.30.2